--------------------------------------------------------------------------------
-- 
-- S3PICPROG - PIC programmer with S3 starter kit
-- Copyright (C) 2008 Olivier Ringot <oringot@gmail.com>
-- 
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 2
-- of the License, or (at your option) any later version.
-- 
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
-- 
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, 
-- Boston, MA  02110-1301, USA.
-- 
--------------------------------------------------------------------------------
-- 
-- $Revision: $
-- $Date: $
-- $Source: $
-- $Log: $
--
--------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;

package s3picprog_pkg is

  component s3picprog
    port                                                     
    (                                                        
      -- system                                              
      osc50          :    in std_logic;                      
                                                             
      -- switch                                              
      pbutton        :    in std_logic_vector( 3 downto 0);  
      switch         :    in std_logic_vector( 7 downto 0);  
                                                             
      -- led                            
      led            :   out std_logic_vector( 7 downto 0);  
                                                             
      -- rs-232                                              
      uart_t2h       :   out std_logic;                      
      uart_h2t       :    in std_logic;                      
      uart_p2t       :    in std_logic;                      
      uart_t2p       :   out std_logic;                      
                                                             
      -- PIC interface                                       
      pic_mclr       : inout std_logic;                      
      pic_pgm        : inout std_logic;                      
      pic_pgc        : inout std_logic;                      
      pic_pgd        : inout std_logic;                      
    
      -- unused
      anode_s7       :   out std_logic_vector( 3 downto 0);
      s7             :   out std_logic_vector( 7 downto 0);
      --
      sram_csn       :   out std_logic_vector( 1 downto 0);
      sram_ben       :   out std_logic_vector( 3 downto 0);
      sram_oen       :   out std_logic;
      sram_wen       :   out std_logic;
      sram_a         :   out std_logic_vector(17 downto 0);
      sram_dq        : inout std_logic_vector(31 downto 0)
    );                                                       
  end component;
  
  component uart
    port 
    (
      -- system
      resetn   :  in std_logic;
      clk      :  in std_logic;
      clken    :  in std_logic;
      
      -- tx
      wen      :  in std_logic;
      data_in  :  in std_logic_vector( 7 downto 0);
      busy     : out std_logic;
      tx       : out std_logic;
      
      -- rx
      rx       :  in std_logic;
      data_out : out std_logic_vector( 7 downto 0);
      valid    : out std_logic
    ); 
  end component;

  component icsp
    port
    (
      -- system
      resetn        :  in std_logic;
      clk           :  in std_logic;
      
      -- control 
      start         :  in std_logic;
      done          : out std_logic;
      command       :  in std_logic_vector( 3 downto 0);
      datai         :  in std_logic_vector(15 downto 0);
      datao         : out std_logic_vector( 7 downto 0);
       
      -- delays
      delay_hperiod :  in std_logic_vector(15 downto 0);
      delay_prog    :  in std_logic_vector(15 downto 0);
      delay_erase   :  in std_logic_vector(15 downto 0);
      
      -- PIC pins
      pgc           : out std_logic;
      pgdo          : out std_logic;
      pgdi          :  in std_logic;
      pgde          : out std_logic
      
    );
  end component;

end package s3picprog_pkg;
